import type { CLTableProps, CLTableActions } from "../types";

/**
 * @description table入口，创建 register 事件函数、方法methods
 * @param  props 需要传入的配置项
 * @returns  -{ register,methods }
 */
export default function useTable(props: CLTableProps) {
  /** shallowRef 只对第一层做响应式 */
  const methods = shallowRef({} as CLTableActions);
  function register(instance: CLTableActions) {
    methods.value = instance;
    instance.setProps(props);
  }

  return { register, methods };
}
